package com.blue.ocean.hole.async;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("async")
public class AsyncController {

    @Autowired
    private AsyncService asyncService;

    @PostMapping("/execute")
    public void execute(@RequestBody Job job){
        for(int i = 0 ; i < 100; i++){
            asyncService.execute(job);
        }
    }


    @PostMapping("/execute2")
    public void execute2(@RequestBody Job job){
        for(int i = 0 ; i < 100; i++){
            asyncService.execute2(job);
        }
    }
}
